package com.example.controller;

import com.example.dto.UserRoleDto;
import com.example.dto.UserStatusDto;
import com.example.entity.LoginUser;
import com.example.entity.User;
import com.example.service.MenuService;
import com.example.service.RoleService;
import com.example.service.UserService;
import com.example.utils.BeanCopyUtils;
import com.example.utils.ResponseResult;
import com.example.utils.SecurityUtils;
import com.example.vo.AdminUserInfoVo;
import com.example.vo.UserInfoVo;
import com.example.vo.UserRoleIdVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;
import java.util.List;

@RestController
@RequestMapping("system/user")
public class SystemUserController {

    @Autowired
    private MenuService menuService;

    @Autowired
    private RoleService roleService;

    @Autowired
    private UserService userService;

    @GetMapping("/list")
    public ResponseResult getList(@PathParam("pageNum") int pageNum, @PathParam("pageSize") int pageSize, @PathParam("userName") String userName, @PathParam("phonenumber") String phonenumber,@PathParam("status") String status){
        return userService.getList(pageNum,pageSize,userName,phonenumber,status);
    }

    @DeleteMapping("/{ids}")
    public ResponseResult deleteUsers(@PathVariable List<Long> ids){
        return ResponseResult.okResult(userService.removeByIds(ids));
    }

    @GetMapping("/{id}")
    public ResponseResult getUser(@PathVariable Long id){
        return userService.getUser(id);
    }

    @PutMapping("changeStatus")
    public ResponseResult changeStatus(@RequestBody UserStatusDto userStatusDto){
        return userService.changeStatus(userStatusDto);
    }

    @PutMapping()
    public ResponseResult updateUser(@RequestBody UserRoleDto userRoleDto){
        return userService.updateUser(userRoleDto);
    }
}
